import request from '../../utils/Request'

export const listMenuTree = bId => {
  if (bId === undefined || bId === null) {
    bId = 0
  }
  return request({
    method: 'get',
    url: '/api/manage/menu/list/tree/' + bId,
    params: {}
  })
}

/*查询当前用户系统列表*/
export const listSystemByUser = () => {
  return request({
    method: 'get',
    url: '/api/manage/menu/list/user/system',
    params: {}
  })
}

/*查询当前用户指定系统下的菜单树*/
export const listUserMenuTreeBySystem = bId => {
  return request({
    method: 'get',
    url: '/api/manage/menu/list/tree/system/' + bId,
    params: {}
  })
}

export const listMenu = data => {
  return request({
    method: 'get',
    url: '/api/manage/menu/list',
    params: data
  })
}

export const listMenuByRoleId = roleId => {
  return request({
    method: 'get',
    url: '/api/manage/menu/list/role/' + roleId,
    params: {}
  })
}

export const saveMenu = data => {
  return request({
    method: 'post',
    url: '/api/manage/menu/save',
    data: data
  })
}

export const createMenu = data => {
  return request({
    method: 'post',
    url: '/api/manage/menu/create',
    data: data
  })
}

export const updateMenu = data => {
  return request({
    method: 'post',
    url: '/api/manage/menu/update',
    data: data
  })
}

export const updateMenuStatus = (menuId, status) => {
  return request({
    method: 'get',
    url: '/api/manage/menu/' + menuId + '/status/' + status,
    params: {}
  })
}

export const deleteMenu = bId => {
  return request({
    method: 'get',
    url: '/api/manage/menu/delete/' + bId,
    params: {}
  })
}
